<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            color: green;
            font-weight:800;
            opacity:.5 ;
        }
    </style>
</head>
<body>
    <!-- data-属性名：自定义属性 -->
    <a href="#" class="lj" data-index='123'>空链接</a>
</body>
<script>
    //获取元素
    const em1=document.querySelector('.lj');
    console.log(em1.href);  //对象.属性

    em1.innerText='百度一下';
    em1.href='https://wwww.baidu.com';
    console.log(em1.href);

    em1.innerText='小米官网';
    em1.setAttribute('href','https://www.mi.com');

    console.log(em1.getAttribute('data-index'))
    em1.dataset.index='456';  //设置自定义属性值
    console.log(em1.getAttribute('data-index'));
    console.log(em1.dataset['index']);
    em1.removeAttribute('href');
    console.log('-----------------');
    em1.style.color='red';
    em1.style.fontSize='26px';
    em1.className='lj box';
</script>
</html>